package com.stellar.auth.controller.admin.authRolePermission;

import com.stellar.auth.controller.admin.authRolePermission.vo.AuthRolePermissionRequestPageVO;
import com.stellar.auth.controller.admin.authRolePermission.vo.AuthRolePermissionRequestVO;
import com.stellar.auth.controller.admin.authRolePermission.vo.AuthRolePermissionResponseVO;
import com.stellar.auth.domain.authRolePermission.AuthRolePermissionDomainService;

import com.stellar.web.core.bean.PageResult;
import com.stellar.web.core.bean.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 角色权限关联表控制器
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-16 18:07:33
 */
@RequestMapping("/api-admin/authRolePermission")
@RestController("adminAuthRolePermissionController")
@Slf4j
public class AuthRolePermissionController {

    @Resource
    private AuthRolePermissionDomainService authRolePermissionDomainService;

    /**
     * 分页查询角色权限关联表
     */
    @PostMapping("/page")
    public Result<PageResult<AuthRolePermissionResponseVO>> page(@RequestBody AuthRolePermissionRequestPageVO requestPageVO) {
        return Result.success(authRolePermissionDomainService.page(requestPageVO));
    }

    /**
     * 新增角色权限关联表
     */
    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody AuthRolePermissionRequestVO requestVO) {
        return Result.success(authRolePermissionDomainService.insert(requestVO));
    }

    /**
     * 修改角色权限关联表
     */
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody AuthRolePermissionRequestVO requestVO) {
        return Result.success(authRolePermissionDomainService.update(requestVO));
    }

    /**
     * 删除角色权限关联表
     */
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Long id) {
        return Result.success(authRolePermissionDomainService.delete(id));
    }

    /**
     * 获取角色权限关联表详情
     */
    @GetMapping("/get/{id}")
    public Result<AuthRolePermissionResponseVO> get(@PathVariable("id") Long id) {
        return Result.success(authRolePermissionDomainService.get(id));
    }
}
